{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Generate rate capability plots"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this notebook we use PyBaMM to generate rate capability plots and Ragone plots. Rate capability plots show discharge capacity at different C-rates. Similarly, multiplying the discharge current and capacity by the average discharge voltage we can obtain Ragon plots (that is energy vs power).\n",
    "\n",
    "First we need to import pybamm and the other necessary packages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip install \"pybamm[plot,cite]\" -q    # install PyBaMM if it is not installed\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "import pybamm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this example we use the SPMe model with the default settings, but we could change it to other models, parameters, geometries... For example, you generate rate capability plots using the DFN model in [this script](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/scripts/rate_capability.py). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "model = pybamm.lithium_ion.SPMe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We now cycle a loop of different C-rates and run full discharge simulations for each C-rate. For each simulation we register the final discharge capacity, the applied current and the average discharge voltage. We can then generate the rate capability and the Ragone plots."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXa0lEQVR4nO3df7DldX3f8eeLBcKO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gT3ASjqtXm4EPgO8HziDTgfW66rqvzZxLtIwBv11I+mpzqDzTIlhrAVeVlWHk5wIvKKqnkjyS8C7q+p1Sf4DnT7+VwEkeTedFhG/3m2V8cUkf1lVP2zgXKR5GRBSMz5RVYe73z8b+OMk6+m0Zj5ujvecT6fh3Lu62ycA6+i0hJGWnAEhDW8n8M9n70zyW3QeVEO3xTZA71/9NwB3VtVru8+l+Ks5Pj/A66pq9yLVKx0VJ6ml4d0B/FTvQ1mSvAj4XFWd1RMOsz2bJ1vKv7Vn/w+AZ/VsbwXe3p0MJ8nZi1S3tCAGhDSk6tzR8Vrgl7q3ue6kM7n8f+Z563uBG5Ps4KlX7XcCp3e7zL6ezpXGccBXup99w6KfhHQEvItJktSXVxCSpL4MCElSXwaEJKkvA0KS1JcBIUnqy4CQJPVlQEiS+jIgJEl9/T8QcWY4wpe+MwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEHCAYAAACjh0HiAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAW00lEQVR4nO3de7BlZXnn8e9vsKOtoJ2EjoaGTpsSsDSAbY5GJeM1RnSM4mVqnDhoJqY6GkchQUzAqVSSqdIYEmIyjhAGMmrCmFJBdJwo9hhScpN4umlp6Y6XwRvQDo1RQO1SWp75Y6+Ww+Gcffbp3mvf1vdTtYt99lp77WcXXed31rvW876pKiRJ3fWvxl2AJGm8DAJJ6jiDQJI6ziCQpI4zCCSp4wwCSeq4B7V14CTHAO8FHgkUcGFV/cUS+z0TeAewBrijqp7R77hHHnlkbdq0acjVStJs27Zt2x1VtX6pba0FAbAfOLOqtic5AtiWZGtV7T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ktRxBoEkdZxBIEkd9/8BqTQ8+FdozkUAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "C_rates = np.linspace(0.05, 5, 20)\n",
    "capacities = np.zeros_like(C_rates)\n",
    "currents = np.zeros_like(C_rates)\n",
    "voltage_av = np.zeros_like(C_rates)\n",
    "\n",
    "for i, C_rate in enumerate(C_rates):\n",
    "    experiment = pybamm.Experiment([f\"Discharge at {C_rate:.4f}C until 3.2V\"])\n",
    "    sim = pybamm.Simulation(model, experiment=experiment)\n",
    "    sim.solve()\n",
    "\n",
    "    time = sim.solution[\"Time [s]\"].entries\n",
    "    capacity = sim.solution[\"Discharge capacity [A.h]\"]\n",
    "    current = sim.solution[\"Current [A]\"]\n",
    "    voltage = sim.solution[\"Voltage [V]\"]\n",
    "\n",
    "    capacities[i] = capacity(time[-1])\n",
    "    currents[i] = current(time[-1])\n",
    "    voltage_av[i] = np.mean(voltage(time))\n",
    "\n",
    "plt.figure(1)\n",
    "plt.scatter(C_rates, capacities)\n",
    "plt.xlabel(\"C-rate\")\n",
    "plt.ylabel(\"Capacity [Ah]\")\n",
    "\n",
    "plt.figure(2)\n",
    "plt.scatter(currents * voltage_av, capacities * voltage_av)\n",
    "plt.xlabel(\"Power [W]\")\n",
    "plt.ylabel(\"Energy [Wh]\")\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "The relevant papers for this notebook are:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.\n",
      "[2] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.\n",
      "[3] Scott G. Marquis, Valentin Sulzer, Robert Timms, Colin P. Please, and S. Jon Chapman. An asymptotic derivation of a single particle model with electrolyte. Journal of The Electrochemical Society, 166(15):A3693–A3706, 2019. doi:10.1149/2.0341915jes.\n",
      "[4] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). ECSarXiv. February, 2020. doi:10.1149/osf.io/67ckj.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "pybamm.print_citations()"
   ]
  }
 ],
 "metadata": {
  "file_extension": ".py",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  },
  "mimetype": "text/x-python",
  "name": "python",
  "npconvert_exporter": "python",
  "pygments_lexer": "ipython3",
  "version": 3
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
